package com.lzx.dormsys.controller;

import java.util.List;

import com.lzx.dormsys.core.AjaxResult;
import com.lzx.dormsys.core.controller.BaseController;
import com.lzx.dormsys.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lzx.dormsys.bean.DoorBean;
import com.lzx.dormsys.service.IDoorBeanService;

/**
 * doorController
 *
 * @author lzx
 * @date 2021-09-10
 */
@RestController
@RequestMapping("/doorAction")
public class DoorBeanController extends BaseController
{
    @Autowired
    private IDoorBeanService doorBeanService;

    /**
     * 查询door列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DoorBean doorBean)
    {
        startPage();
        List<DoorBean> list = doorBeanService.selectDoorBeanList(doorBean);
        return getDataTable(list);
    }

    /**
     * 获取door详细信息
     */
    @GetMapping(value = "/{doorId}")
    public AjaxResult getInfo(@PathVariable("doorId") Long doorId)
    {
        return AjaxResult.success(doorBeanService.selectDoorBeanById(doorId));
    }

    /**
     * 新增door
     */
    @PostMapping
    public AjaxResult add(@RequestBody DoorBean doorBean)
    {
        return toAjax(doorBeanService.insertDoorBean(doorBean));
    }

    /**
     * 修改door
     */
    @PutMapping
    public AjaxResult edit(@RequestBody DoorBean doorBean)
    {
        return toAjax(doorBeanService.updateDoorBean(doorBean));
    }

    /**
     * 删除door
     */
	@DeleteMapping("/{doorIds}")
    public AjaxResult remove(@PathVariable Long[] doorIds)
    {
        return toAjax(doorBeanService.deleteDoorBeanByIds(doorIds));
    }
}
